<?php
	/*
		Created by using  the User_Login page as a template

		Created by			:	Daniel Ramsdell
		Created On			:	29.August.2011
		Last Modification	:	Change username to home_electronics
		Modified On			:	06.September.2011
		Modified By			:	Daniel Ramsdell
	*/




	//include the functions.php
	require "include/functions.php";

	check_session();
	check_admin();
?>

<html>
<head>
<title>Home Electronics - Order History</title>
<link rel="stylesheet" href="include/styles.css" type="text/css">
<script src="include/functions.js"></script>
<script>window.onload=function(){
	altRows('alternatecolor');
}</script>
</head>
<body>
<div id="container" align="center">
  
	
	<div id="body" align="center">
		<div>
	<?php
		print('

			<h1>Order History</h1> 
			<a>');
			
		//	declare tables to be used as a single string
		$tables 	=		(	
								"product p, product_stock_order pso, stock_order so"
							);
		//	declare table rows as an array
		$table_rows = array (	
								"so.stock_order_number",
								"so.order_date",
								"so.received", 
								"pso.order_quantity",
								"p.product_name",
								"p.category"
							);
		//	merge tables by the id fields
		$condition	=		(
								"(p.product_id = pso.product_id AND ".
								"so.stock_order_number = pso.stock_order_number)"
							);
		//	output table headers
		echo("<table class='altrowstable' id='alternatecolor'><tr><th>Order<br />Number</th><th>Order Date</th><th>Received On</th><th>Amount<br/>Ordered</th><th>Name</th><th>Category</th></tr>");
		//	get data from database
		$result = query_table("home_electronics", "home", "home_e", $tables, $table_rows, $condition, false, false);
		//	print data and close HTML tags
		echo($result."</table></a>");
	?>
		
		</div>
	</div> <!--body div -->
   		
</div>
</body>
</html>




